package study.java.jdk.jdk8._5_lambda.op;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

@Slf4j
public class Operation_Test {

    @Test
    public void test1() {
        //类型声明
        Operation add = (int a, int b) -> a + b;
        //不用类型声明
        Operation sub = (a, b) -> a - b;
        //大括号中的返回语句
        Operation multi = (int a, int b) -> {
            return a * b;
        };
        //没有大括号及返回语句
        Operation div = (int a, int b) -> a / b;

        log.info("10+5 = {}", operate(10, 5, add));
        log.info("10-5= {}", operate(10, 5, sub));
        log.info("10x5= {}", operate(10, 5, multi));
        log.info("10/5= {}", operate(10, 5, div));
    }

    int operate(int a, int b, Operation op) {
        return op.operation(a, b);
    }
}
